package com.eamois.dao.graph.impl;

import java.sql.SQLException;
import java.util.Collection;

import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.eamois.dao.graph.GraphPolygonDao;
import com.eamois.dao.impl.BaseDaoImpl;
import com.eamois.domain.graph.GraphLine;
import com.eamois.domain.graph.GraphPolygon;
import com.eamois.domain.graph.GraphTemplate;

public class GraphPolygonDaoImpl extends BaseDaoImpl<GraphPolygon> implements GraphPolygonDao{

	@Override
	@SuppressWarnings("unchecked")
	public Collection<GraphPolygon> findGraphPolygonByTemplate(
			final GraphTemplate graphTemplate) {
		// TODO Auto-generated method stub

		return (Collection<GraphPolygon>) this.getHibernateTemplate().execute(new HibernateCallback() {

			@Override
			public Object doInHibernate(Session arg0)
					throws HibernateException, SQLException {
				// TODO Auto-generated method stub
				Criteria criteria = arg0.createCriteria(GraphPolygon.class);
				criteria.add(Restrictions.eq("graphTemplate", graphTemplate));
				return criteria.list();
			}
		});
	}

}
